<?php


namespace custom;


use app\common\lib\RespCode;

class TencentMap {

    /**
     * 当前对象
     * @var
     */
    protected static $instance;

    public $key = 'ENWBZ-G2GWJ-2BUFP-K5PG5-X3O4T-5OBBO';

    public function BaiduLocation2TenXunLocation($data, &$ret) {
        $data['key'] = $this->key;
        $data_str = http_build_query($data);
        $res = Curl::getInstance()->xhr('GET', 'https://apis.map.qq.com/ws/coord/v1/translate?' . $data_str, []);
        $res = json_decode($res, true);
        $messages = iconv('UTF-8', 'GBK//IGNORE', $res['message']);
//        $messages = $res['message'];
        Log::write("messages:{$messages}|status:{$res['status']}", 'common-BaiduLocation2TenXunLocation.log');
        if (empty($res)) $ret = -1;
        if (!isset($res['status'])) $ret = -1;
        $ret = $res;
    }

    public static function getInstance() {
        if (!self::$instance instanceof self) {
            self::$instance = new self();
        }
        return self::$instance;
    }

}